<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" name="viewport" />
<meta name="format-detection" content="telephone=no">
<meta charset="utf-8">
<title>实力印证 拥抱合规</title>
<script type="text/javascript" src="./js/flexible.js"></script>
<style>
*{
	margin: 0;
	padding: 0;
}
img{
	box-sizing: border-box;
	max-width: 100%;
	height: auto;
	vertical-align: middle;
	border: 0;
}
li{
	list-style: none;
	text-align: left;
	padding-left: 5px;
}
a{
	text-decoration: none;
	color: #FFF;
}
.wrapper{
	min-height: 4.24rem;
	width: 9.24rem;
	margin: 0.78rem auto;
	padding: 0 0.16rem;
	position: relative;
	padding-bottom: 15px;
	background: #1b1714 url(img/light-bg-4.png) top center no-repeat;
	background-size: 100%;
}
.light {
	position: absolute;
	left: 0;
	top: -0.35rem;
	width: 9.56rem;
	height: 0.70rem;
	z-index: 8
}
.title {
	padding-top: 0.7rem;
	margin-bottom: 0.36rem;
	font-size: 18px;
	font-family: '微软雅黑';
	background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgba(253, 246, 190, 1)), to(rgba(245, 166, 75, 1)));
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	text-align: center;
}
.title-1 {
	font-size: 18px;
	font-family: '微软雅黑';
	background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgba(253, 246, 190, 1)), to(rgba(245, 166, 75, 1)));
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	text-align: center;
}
.font-color {
	color: #dcad75;
}
.raiders {
	font-size: 14px;
	line-height: 24px;
}
.flex {
	display: flex;
	flex-wrap: wrap;
}
.flex-1 {
	flex: 1;
}
.jc-space-between {
	justify-content: space-between;
}
.jc-space-center {
	justify-content: center;
}
.ai-center {
	align-items: center;
}
.calc_invest{
	color: #dcad75;
	font-size: 12px;
	margin: 0.2rem 0 0.4rem 0;
}
.calc_invest input{
	width: 1.75rem;
	height: 0.94rem;
	border: 1px solid #dcad75;
	text-align: center;
	font-size: 14px !important;
	background: #ffddb4;
}
input::-webkit-input-placeholder{
	color: #1e1a16 !important;
}
input:-moz-placeholder{
	color: #1e1a16 !important;
}
input:-moz-placeholder, textarea:-moz-placeholder {
　　color: #1e1a16 !important;
}
input:-ms-placeholder{
	color: #1e1a16 !important;
}
.btn-rules {
	border: 1px solid #dcad75;
	border-radius: 5px;
	padding: 0px 8px;
	height: 24px;
	line-height: 24px;
}
.convert-wrap {
	margin-top: 0.2rem;
	width: 2.736rem;
	background: #ad7d45;
	padding: 0.107rem;
}
.convert-wrap:nth-child(1) {
	border-radius: 15px 0 0 0;
}
.convert-wrap:nth-child(3) {
	border-radius: 0 15px 0 0;
}
.btn-convert {
	color: #ffca9b;
	font-size: 16px;
	heihgt: 0.77rem;
	line-height: 0.77rem;
	background: #432514;
	text-align: center;
}
.convert-last {
	width: 9.206rem;
	background: #ad7d45;
	padding: 0.107rem;
	margin-top: 0.2rem;
	border-radius: 0 0 15px 15px;
}
.btn-convert-last {
	width: 2.3rem;
	height: 0.8rem;
	line-height: 0.8rem;
	text-align: center;
	background: #432514;
	border-radius: 5px;
	color: #ffca9b;
	font-size: 16px;
}
.btn-shake {
	width: 4.08rem;	
	margin: 0.64rem auto 0.2rem; 
	border-radius: 8px;
}
.tab-prize {
	width: 100%;
	text-align: center;
	color: #dcad75;
	border-collapse: collapse;
	margin-top: 10px;
}
.tab-prize tr td {
	height: 0.72rem;
	line-height: 0.72rem;
}
.tab-prize tr:nth-child(even) {
	background: #2d1e12;
}
.tab-prize tr:nth-child(odd) {
	background: #413429;
}
.mask{
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.6);
	z-index: 98;
	display: none;	
}
.convert-rules, .shake-rules{
	width: 8.2rem;
	background: #FFF;
	color: #432514;
	position: fixed;
	left: 50%;
	top: 50%;
	margin-left: -4.5rem;
	padding: 0.4rem;
	border-radius: 12px;
	z-index: 99;
	display: none;
}
.tab-rule {
	width: 100%;
}
.tab-rule tr td:first-child {
	vertical-align: top;
}
.tab-rule tr td {
	line-height: 20px;
}
.convert-popup {
	position: fixed;
	width: 7.0rem;
	height: 6.2rem;
	left: 50%;
	top: 50%;
	margin-left: -3.5rem;
	margin-top: -3.1rem;
	background: url(img/convert-pop-bg.png) center bottom;
	background-size: 100%;
	z-index: 99;
	display: none;
}
.convert-popup p {
	line-height: 20px;
	font-size: 14px;
}
.convert-popup p span {
	color: #656565;
	font-size: 12px;
}
.btn-rules-sure {
	text-align: center;
	width: 1.8rem;
	height: 0.72rem;
	line-height: 0.72rem;
	margin: 0.2rem auto;
	border: 1px solid #dcad75;
	border-radius: 8px;	
}
.button {
	text-align: center;
	width: 1.8rem;
	height: 0.72rem;
	line-height: 0.72rem;
	border: 1px solid #FFF;
	border-radius: 8px;
	color: #FFF;
}
.can-status, .btn-convert-sure {
	position: absolute;
	bottom: 0.64rem;
}
.btn-convert-sure {
	left: 50%;
	margin-left: -0.9rem;
}
.btn-cancel, .btn-sure {
	margin: 0 auto;
}
.can-status {
	text-align: center;
	left: 0;
	width: 100%;
}
.shake-popup {
	position: fixed;
	left: 50%;
	width: 7.0rem;
	margin-left: -3.5rem;
	padding-top: 2.96rem;
	z-index: 99;
	top: 50%;
	background: #FFF;
	border-radius: 8px;
	text-align: center;
	display: none;
}
.btn-shake-sure {
	width: 2.36rem;
	height: 0.78rem;
	line-height: 0.78rem;
	border-radius: 8px;
	margin: 10px auto 15px;
	background: -webkit-linear-gradient(left,#fda031,#fff13b);
	background: linear-gradient(to right,#fda031,#fff13b);
}
.shakemoneytree {

}
@-webkit-keyframes shake {
	from, to {
		-webkit-transform: rotate3d(0,0,0,0);
		transform: rotate3d(0,0,0,0);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}

	10%, 30%, 50%, 70%, 90% {
		-webkit-transform: rotate3d(0,0,1,-6deg);
		transform: rotate3d(0,0,1,-6deg);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}

	20%, 40%, 60%, 80% {
		-webkit-transform: rotate3d(0,0,1,6deg);
		transform: rotate3d(0,0,1,6deg);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}
}

@keyframes shake {
	from, to {
		-webkit-transform: rotate3d(0,0,0,0);
		transform: rotate3d(0,0,0,0);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}

	10%, 30%, 50%, 70%, 90% {
		-webkit-transform: rotate3d(0,0,1,-6deg);
		transform: rotate3d(0,0,1,-6deg);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}

	20%, 40%, 60%, 80% {
		-webkit-transform: rotate3d(0,0,1,6deg);
		transform: rotate3d(0,0,1,6deg);
		-webkit-transform-origin: bottom center;
		transform-origin: bottom center;
	}
}

.shake {
	-webkit-animation: shake 1s;
	animation: shake 1s;
}

.btn-online-close {
	width: 30px;
	position: absolute;
	left: 50%;
	bottom: -52px;
	margin-left: -15px;
	z-index: 99;
}

.maskimg{
	position:fixed;
	left:0;
	top:0;
	z-index:100;
	height: 100%;
	display:none;
}

.maskimg img{
	width:93%;
}
</style>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	$(function() {
		var shareurl = 'http://8.laicunba.com/h5/regist_new.jsp?invite_code=${inviteCode}&mobile=${mobile}';
		if($("#channel").val()) {
			shareurl += "&channel=${param.channel}";
		}
		wx.config({
			debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			appId : '${weiXinVO.appid}', // 必填，公众号的唯一标识
			timestamp :'${weiXinVO.timestamp}', // 必填，生成签名的时间戳
			nonceStr : '${weiXinVO.nonceStr}', // 必填，生成签名的随机串
			signature :'${weiXinVO.signature}',// 必填，签名，见附录1
			 jsApiList: ['onMenuShareQZone',
				'onMenuShareTimeline',
				'onMenuShareAppMessage',
				'onMenuShareQQ',
				'onMenuShareWeibo',
				'hideMenuItems',
				'showMenuItems',
				'hideAllNonBaseMenuItem',
				'showAllNonBaseMenuItem',
				'translateVoice',
				'startRecord',
				'stopRecord',
				'onRecordEnd',
				'playVoice',
				'pauseVoice',
				'stopVoice',
				'uploadVoice',
				'downloadVoice',
				'chooseImage',
				'previewImage',
				'uploadImage',
				'downloadImage',
				'getNetworkType',
				'openLocation',
				'getLocation',
				'hideOptionMenu',
				'showOptionMenu',
				'closeWindow',
				'scanQRCode',
				'chooseWXPay',
				'openProductSpecificView',
				'addCard',
				'chooseCard',
				'openCard']
		// 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		});

		wx.ready(function() {
			// config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，
			// config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，
			// 则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，
			// 则可以直接调用，不需要放在ready函数中。

			wx.onMenuShareAppMessage({
				title : '要理财,来存吧!', // 分享标题
				desc : '来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!', // 分享描述
				link :shareurl, // 分享链接
				imgUrl : 'http://8.laicunba.com/h5/img/sharelogo.png', // 分享图标
				type : '', // 分享类型,music、video或link，不填默认为link
				dataUrl : '', // 如果type是music或video，则要提供数据链接，默认为空
				success : function() {
					// 用户确认分享后执行的回调函数
				},
				cancel : function() {
					// 用户取消分享后执行的回调函数
				}
			});

			wx.onMenuShareTimeline({
				title : '要理财,来存吧!来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!', // 分享标题
				link : shareurl, // 分享链接
				imgUrl : 'http://8.laicunba.com/h5/img/sharelogo.png', // 分享图标
				success : function() {
					// 用户确认分享后执行的回调函数
				},
				cancel : function() {
					// 用户取消分享后执行的回调函数
				}
			});
			
			wx.onMenuShareQQ({
				title: '要理财,来存吧!', // 分享标题
				desc: '来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!', // 分享描述
				link: shareurl, // 分享链接
				imgUrl: 'http://8.laicunba.com/h5/img/sharelogo.png', // 分享图标
				success : function() {
					// 用户确认分享后执行的回调函数
				},
				cancel : function() {
					// 用户取消分享后执行的回调函数
				}
			});
			
			wx.onMenuShareQZone({
				title: '要理财,来存吧!', // 分享标题
				desc: '来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!', // 分享描述
				link: shareurl, // 分享链接
				imgUrl: 'http://8.laicunba.com/h5/img/sharelogo.png', // 分享图标
				success : function() {
					// 用户确认分享后执行的回调函数
				},
				cancel : function() {
					// 用户取消分享后执行的回调函数
				}
			});

		}); 
	}); 
</script>
</head>
<body style="background: #000;">
<div style="width: 100%;text-align: center;"><img src="http://laicunba.b0.upaiyun.com/lcb/activity/celebrate_depository_top.png" /></div>
<div class="wrapper">
<!--	<img src="img/light-bg-2.png" class="light"> -->
	<div class="title">活动攻略</div>
	<p class="raiders font-color">1.投资银票宝大于15天以上项目可参与本次活动</p>
	<p class="raiders font-color">2.计算器：</p>
	<div class="calc_invest flex jc-space-center">
		<div>
			<input type="number" id="input_amount" style="width: 2.0rem" placeholder="投资本金" /> * 
			<input type="number" id="input_period" style="width: 1.4rem" placeholder="天数" /> /365=
			<input type="number" id="compute_result" readonly="readonly" placeholder="" /> 年化投资金
		</div>
	</div>
</div>
<div class="wrapper">
	<div class="title">超值福利兑换商城</div>
	<div class="flex jc-space-between font-color ai-center">
		<div style="font-size: 16px;">当前年化投资金：<a href="javascript:void(0);" id="investBill" class="font-color" style="font-size: 18px;"><c:choose><c:when test="${loginStatus == '1' }"><c:choose><c:when test="${vcoinBalance > 0 }">${vcoinBalance } »</c:when><c:otherwise>0 »</c:otherwise></c:choose></c:when><c:otherwise>***** »</c:otherwise></c:choose></a></div>
		<div class="btn-rules btn-rules-convert">活动规则</div>
	</div>
	<div class="flex jc-space-between font-color">
		<div class="convert-wrap convert-first">
			<img src="img/online-cash-50.png" />
			<div class="btn-convert" rel="001">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-jd-50.png" />
			<div class="btn-convert" rel="002">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-cash-150.png" />
			<div class="btn-convert" rel="003">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-jd-200.png" />
			<div class="btn-convert" rel="004">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-cash-300.png" />
			<div class="btn-convert" rel="005">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-cash-500.png" />
			<div class="btn-convert" rel="006">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-cash-700.png" />
			<div class="btn-convert" rel="007">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-ipad.png" />
			<div class="btn-convert" rel="008">兑换 »</div>
		</div>
		<div class="convert-wrap">
			<img src="img/online-iphone.png" />
			<div class="btn-convert" rel="009">兑换 »</div>
		</div>
		<div class="convert-wrap convert-last">
			<div class="flex jc-space-between ai-center" style="background: #FFF;border-radius: 0 0 15px 15px;padding: 10px 0.33rem;">
				<div><img src="http://laicunba.b0.upaiyun.com/lcb/activity/celebrate_depository_online_mk.png" style="width: 5.34rem;" /></div>
				<div class="btn-convert btn-convert-last" rel="010">兑换 »</div>
			</div>
		</div>
	</div>
	<div style="text-align: right;margin-top: 10px;color: #a9855a;"><a href="javascript:void(0);" id="convertBill" style="color: #a9855a; font-size:18px;">查看兑换详情 »</a></div>
</div>
<div class="wrapper">
	<div class="title">摇钱树</div>
	<div class="flex jc-space-between font-color ai-center">
		<div style="font-size: 16px;">剩余摇奖次数：<span class="font-color"><c:choose><c:when test="${loginStatus == '1' }"><c:choose><c:when test="${shakeChance > 0 }">${shakeChance } </c:when><c:otherwise>0 </c:otherwise></c:choose></c:when><c:otherwise>* </c:otherwise></c:choose></span>次</div>
		<div class="btn-rules btn-rules-shake">活动规则</div>
	</div>
	<div class="shakemoneytree"><img src="http://laicunba.b0.upaiyun.com/lcb/activity/celebrate_depository_shake_coin.png" /></div>
	<div class="btn-shake" rel="011"><img src="img/btn-shake.png" /></div>
	<div class="font-color" style=" text-align: center;">注：点击按钮或者用力摇手机均可摇奖</div>
	<div class="flex jc-space-between" style="height: 30px;line-height: 30px;margin-top: 15px;">
		<div style="width: 2.96rem;"><img src="img/prize-left-line.png" /></div>
		<div class="title-1">奖品展示</div>
		<div style="width: 2.96rem;"><img src="img/prize-right-line.png" /></div>
	</div>
	<div style="text-align: center;color: #a9855a;"><a href="javascript:void(0);" id="shakeBill" style="color: #a9855a; font-size:18px;">查看获奖详情 »</a></div>
	<table class="tab-prize">
		<tr>
			<td>奖品</td>
			<td>使用条件</td>
		</tr>
		<tr>
			<td>0.5%加息券</td>
			<td>投资>20天以上</td>
		</tr>
		<tr>
			<td>1%加息券</td>
			<td>投资>40天以上</td>
		</tr>
		<tr>
			<td>1.5%加息券</td>
			<td>投资>70天以上</td>
		</tr>
		<tr>
			<td>5%加息券</td>
			<td>投资>150天以上</td>
		</tr>
		<tr>
			<td>5元现金券</td>
			<td>1500元30天以上</td>
		</tr>
		<tr>
			<td>10元现金券</td>
			<td>1500元60天以上</td>
		</tr>
		<tr>
			<td>20元现金券</td>
			<td>2500元60天以上</td>
		</tr>
		<tr>
			<td>30元现金券</td>
			<td>3000元60天以上</td>
		</tr>
		<tr>
			<td>1000元现金券</td>
			<td>10000元150天以上</td>
		</tr>
	</table>
</div>
<div style="text-align: center;margin-bottom: 20px;color: #543827;font-size: 14px;">*活动最终解释权归来存吧所有</div>
<!-- - 弹出框 - -->
<div class="mask"></div>
<div class="maskimg">
	<img src="img/maskimg.png" />
</div>
<!-- - 兑换弹出框 - -->
<div class="convert-popup">
	<div id="pop-content" style="margin-top: 1.48rem;text-align: center;color: #f56119;"></div>
	<div class="button btn-convert-sure" style="display: none;">确定</div>
	<div class="flex can-status" style="display: none;" >
		<div class="flex-1">
			<div class="button btn-cancel">取消</div>
		</div>
		<div class="flex-1">
			<div class="button btn-sure">确认</div>
		</div>
	</div>
</div>
<!-- - 活动规则弹出框 - -->
<div class="convert-rules">
	<div style="text-align: center;margin: 10px;font-size: 16px;">活动规则</div>
	<table class="tab-rule">
		<tr>
			<td>1、</td>
			<td>商城中所有奖品皆由年化投资金领取；</td>
		</tr>
		<tr>
			<td>2、</td>
			<td>现金券奖励手动点击领取后即可立即获得，可在【我的】-【我的红包】中查看；</td>
		</tr>
		<tr>
			<td>3、</td>
			<td>本次活动所有实物奖励均通过正规渠道购买，由第三方提供售后保障；</td>
		</tr>
		<tr>
			<td>4、</td>
			<td>实物奖励将于活动结束后10个工作日内由客服联系，并获取您的收货地址，为您安排寄出。</td>
		</tr>
	</table>
	<div class="btn-rules-sure">确定</div>
</div>
<div class="shake-rules" style="display: none;">
	<div style="text-align: center;margin: 10px; font-size: 16px;">活动规则</div>
	<table class="tab-rule">
		<tr>
			<td>1、</td>
			<td>活动期间新用户注册可获得一次免费摇奖机会；</td>
		</tr>
		<tr>
			<td>2、</td>
			<td>活动期间邀好友注册且投资任意定期标 的，即可获得一次免费摇奖，必须当天摇奖，隔日清零（邀友摇奖每日最多5次摇奖机会）；</td>
		</tr>
		<tr>
			<td>3、</td>
			<td>每次摇奖即消耗300元年化投资金；</td>
		</tr>
		<tr>
			<td>4、</td>
			<td>加息券、现金券奖励在摇奖获取后立即获得，可在（【我的】-【我的红包】）中查看。</td>
		</tr>
	</table>
	<div class="btn-rules-sure">确定</div>
</div>
<audio id="shake-music" src="http://laicunba.b0.upaiyun.com/lcb/activity/celebrate_depository_wx_shake.mp3"></audio>
<!-- - 摇一摇中奖弹出框 - -->
<div class="shake-popup">
	<img src="img/shake-pop-top.png" style="width: 7.0rem;position: absolute;left: 0;top: -1.26rem" />
	<div style="color: #f56119; font-size: 16px;margin-top: 10px;" id="resultTitle"></div>
	<div style="color: #656565; margin-top: 5px;" id="resultContent">请至“我的-红包”查看</div>
	<div class="btn-shake-sure">确定</div>
</div>
<script type="text/javascript" src="activity.js"></script>
<script type="text/javascript">
$(function(){
	var convertHeight = $(".convert-rules").height()/2 + "px";
	var shakeHeight = $(".shake-rules").height()/2 + "px";
	var shakePop = $(".shake-popup").innerHeight()/2 + "px";
	var shakeMusic = document.getElementById("shake-music");
	$(".convert-rules").css({
		marginTop: "-" + convertHeight
	});
	$(".shake-rules").css({
		marginTop: "-" + shakeHeight
	});
	$(".shake-popup").css({
		marginTop: "-" + shakePop
	});
	//兑奖完成按钮
	$(".btn-convert-sure").click(function(){
// 		$(".mask, .convert-popup").hide();
		window.location.reload();
	});
	//是否可以兑奖弹窗的 取消按钮
	$(".btn-cancel").click(function(){
		$(".mask, .convert-popup").hide();
	});
	//兑换奖品的规则
	$(".btn-rules-convert").click(function(){
		$(".mask, .convert-rules").fadeIn();
	});
	//摇奖规则
	$(".btn-rules-shake").click(function(){
		$(".mask, .shake-rules").fadeIn();
	});
	//兑奖、摇奖确认按钮 
	$(".btn-rules-sure").click(function(){
		$(".mask, .convert-rules, .shake-rules").hide();
	});
	//摇奖 领取确定按钮 
	$(".btn-shake-sure").click(function(){
// 		$(".mask, .shake-popup").hide();
		$(".shakemoneytree").removeClass("shake");
		window.location.reload();
	});
	
	$(".maskimg").click(function() {
		$(".mask,.maskimg").hide();
	});
	//运动事件监听
	if (window.DeviceMotionEvent) {
		window.addEventListener('devicemotion',deviceMotionHandler,false);
	} else {
		alert("您的设备不支持摇一摇！");
	}
	
	var SHAKE_THRESHOLD = 3000;
	var last_update = 0;
	var x, y, z, last_x = 0, last_y = 0, last_z = 0;
	
	var canShake = 1;
	function deviceMotionHandler(eventData) {
		var acceleration =eventData.accelerationIncludingGravity;
		var curTime = new Date().getTime();
		if ((curTime-last_update)> 100 && canShake==1) {
			var diffTime = curTime -last_update;
			last_update = curTime;
			x = acceleration.x;
			y = acceleration.y;
			z = acceleration.z;
			var speed = Math.abs(x +y + z - last_x - last_y - last_z) / diffTime * 10000;
			if (speed > SHAKE_THRESHOLD) {
				$(".btn-shake").click();
			}
			last_x = x;
			last_y = y;
			last_z = z;
		}
	}
	
	
	$("input[type='number']").keyup(function() {
		if($("#input_amount").val() && $("#input_period").val()) {
			var input_amount = $("#input_amount").val();
			var input_period = $("#input_period").val();
			$("#compute_result").val(Math.floor(input_amount * input_period / 365));
		} else {
			$("#compute_result").val("");
		}
	});
	
	$(".btn-convert").click(function() {
		$(".mask,.maskimg, .convert-popup,.btn-convert-sure,.can-status").hide();
		var index = Number($(this).attr("rel"));
		var device = '${param.device}';
		var app_token = '${param.app_token}';
		var vcoin = '${vcoinBalance }';
		var param = {
			t :new Date(),
			app_token:app_token
		};
		$.post("celebrate_depository_login_status.htm", param, function(data) {
			if(data.loginStatus == 1) {
				switch(index){
					case 1: 
						if(vcoin >= 5888) {
							$("#pop-content").html('<p>您将消耗<span rel="001" style="color:#f56119; font-size:14px;">5888</span>元年化投资金<br/>兑换50元现金券</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 2: 
						if(vcoin >= 5888) {
							$("#pop-content").html('<p>您将消耗<span rel="002" style="color:#f56119; font-size:14px;">5888</span>元年化投资金<br/>兑换50元京东E卡</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 3: 
						if(vcoin >= 15000) {
							$("#pop-content").html('<p>您将消耗<span rel="003" style="color:#f56119; font-size:14px;">15000</span>元年化投资金<br/>兑换150元现金券</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 4: 
						if(vcoin >= 20000) {
							$("#pop-content").html('<p>您将消耗<span rel="004" style="color:#f56119; font-size:14px;">20000</span>元年化投资金<br/>兑换200元京东E卡</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 5: 
						if(vcoin >= 25000) {
							$("#pop-content").html('<p>您将消耗<span rel="005" style="color:#f56119; font-size:14px;">25000</span>元年化投资金<br/>兑换300元现金券</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 6: 
						if(vcoin >= 41500) {
							$("#pop-content").html('<p>您将消耗<span rel="006" style="color:#f56119; font-size:14px;">41500</span>元年化投资金<br/>兑换500元现金券</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 7: 
						if(vcoin >= 50000) {
							$("#pop-content").html('<p>您将消耗<span rel="007" style="color:#f56119; font-size:14px;">50000</span>元年化投资金<br/>兑换700元现金券</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 8: 
						if(vcoin >= 220000) {
							$("#pop-content").html('<p>您将消耗<span rel="008" style="color:#f56119; font-size:14px;">220000</span>元年化投资金<br/>兑换Ipad mini 4（128G）</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 9: 
						if(vcoin >= 375000) {
							$("#pop-content").html('<p>您将消耗<span rel="009" style="color:#f56119; font-size:14px;">375000</span>元年化投资金<br/>兑换Iphone7（红色、128G）</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					case 10: 
						if(vcoin >= 390000) {
							$("#pop-content").html('<p>您将消耗<span rel="010" style="color:#f56119; font-size:14px;">390000</span>元年化投资金<br/>兑换MacBook Air（13.3英寸）</p>');
							$(".mask, .convert-popup,.can-status").fadeIn();
						} else {
							$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
							$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
						}
						break;
					};
			} else {
				if(device) {
// 					window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
					window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
				} else {
					window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
				}
			}
		}, "json");
	});

	Activity.ready('${param.app_token}', "20170703", "", {
		t:new Date()
	}, function(data){
		$(".can-status .btn-sure").click(function(){
			$(".mask, .convert-popup,.btn-convert-sure,.can-status").hide();
			var index = $("#pop-content p span").attr("rel");
			if(!index) {
				return;
			}
			var device = '${param.device}';
			var app_token = '${param.app_token}';
			var param = {
				t :new Date(),
				app_token:app_token
			};
			Activity.join(index, '', function(jdata){
				if(jdata.code=="SUCCESS"){
					switch(Number(index)){
						case 1: 
						case 3: 
						case 5: 
						case 6: 
						case 7: 
							$("#pop-content").html('<p>恭喜您兑换成功！<br/><span>请至“我的-红包”查看</span></p>');
							break;
						case 2: 
						case 4: 
						case 8: 
						case 9: 
						case 10: 
							$("#pop-content").html('<p>恭喜您兑换成功！<br/><span>客服将在活动结束10天内联系您，<br/>请保持手机畅通！</span></p>');
							break;
					}
					$(".mask,.convert-popup,.btn-convert-sure").fadeIn();
				}else if(jdata.code=="token_error"){
					if(device){
						console.log("app login");
// 						window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
						window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
					}else{
						console.log("h5 login");
						window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
					}
				}else if(jdata.code=="ACT_TIME_INVALID"){
					$("#pop-content").html('<p>抱歉，活动未开始</p>');
					$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
				}else if(jdata.code=="ACTIVITYDO_NOT_EXIST"){
					$("#pop-content").html('<p>抱歉，网络出现异常</p>');
					$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
				}else if(jdata.code=="CONDITIONS_CHECK_FAIL"){
					$("#pop-content").html('<p>抱歉，您的年化投资金<br/>不足以兑换该奖品~</p>');
					$(".mask, .convert-popup,.btn-convert-sure").fadeIn();
				}else{
					console.log("参加活动失败："+JSON.stringify(jdata));
				}
			});
		});
		
		$(".btn-shake").click(function(){
			$(".btn-shake").unbind("click");
			$(".mask,.shake-popup").hide();
			
			var device = '${param.device}';
			var app_token = '${param.app_token}';
			var param = {
				t :new Date(),
				app_token:app_token
			};
			Activity.join('011', '', function(jdata){
				if(jdata.code=="SUCCESS"){
					if(jdata.join_resp == "A") {
						$("#resultTitle").text("恭喜您获得0.5%加息券");
					} else if(jdata.join_resp == "B") {
						$("#resultTitle").text("恭喜您获得5元现金券");
					} else if(jdata.join_resp == "C") {
						$("#resultTitle").text("恭喜您获得10元现金券");
					} else if(jdata.join_resp == "D") {
						$("#resultTitle").text("恭喜您获得20元现金券");
					} else if(jdata.join_resp == "E") {
						$("#resultTitle").text("恭喜您获得30元现金券");
					} else if(jdata.join_resp == "F") {
						$("#resultTitle").text("恭喜您获得1%加息券");
					} else if(jdata.join_resp == "G") {
						$("#resultTitle").text("恭喜您获得1.5%加息券");
					}
					
					shakeMusic.play(); //控制摇奖的声音 
					$(".shakemoneytree").addClass("shake").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){
						$(".shakemoneytree").removeClass("shake");
						$(".mask, .shake-popup").fadeIn();
					});
				}else if(jdata.code=="token_error"){
					if(device){
						console.log("app login");
// 						window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
						window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
					}else{
						console.log("h5 login");
						window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
					}
				}else if(jdata.code=="ACT_TIME_INVALID"){
					$("#resultTitle").text("抱歉，活动未开始");
					$("#resultContent").html("");
					$(".mask, .shake-popup").fadeIn();
				}else if(jdata.code=="ACTIVITYDO_NOT_EXIST"){
					$("#resultTitle").text("抱歉，网络出现异常");
					$("#resultContent").html("");
					$(".mask, .shake-popup").fadeIn();
				}else if(jdata.code=="CONDITIONS_CHECK_FAIL" || jdata.code=="HAS_NO_CHANGE"){
					var htm = '<div class="flex" >'+
									'<div class="flex-1">'+
										'<div class="btn-shake-sure"><a href="/h5/financial_zone.htm?tab=zone&app_view=zone" style="color: #551506">立即投资</a></div>'+
									'</div>'+
									'<div class="flex-1">'+
										'<div class="btn-shake-sure"><a href="javascript:void(0);" id="inviteBtn" style="color: #551506">立即邀请</a></div>'+
									'</div>'+
								'</div>'+
								'<img src="img/btn-online-close.png" class="btn-online-close" />';
					
					$("#resultTitle").text("你还没有摇奖机会哦~");
					$("#resultContent").html("邀请好友首投/300年化投资金<br/>均可获得摇奖机会");
					$(".btn-shake-sure,.btn-online-close").remove();
					$(".shake-popup").append(htm);
					$(".btn-online-close").click(function(){
						$(".shakemoneytree").removeClass("shake");
						window.location.reload();
					});
					
					$("#inviteBtn").click(function() {
						var device = '${param.device}';
						var _channel = '${param._channel}';
						var app_token = '${param.app_token}';
						var param = {
							t :new Date(),
							app_token:app_token
						};
						$.post("celebrate_depository_login_status.htm", param, function(data) {
							if(data.loginStatus == 1) {
								if(device) {
									window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=share";
								} else {
									$(".mask,.shake-popup").hide();
									$(".mask,.maskimg").fadeIn();
								}
							} else {
								if(device) {
// 									window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&_app_version=2.1.9&app_view=login";
									window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
								} else {
									window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
								}
							}
						}, "json");
					});
					$(".mask, .shake-popup").fadeIn();
				}else{
					console.log("参加活动失败："+JSON.stringify(jdata));
				}
			});
		});
	});
	
	$("#investBill").click(function() {
		var device = '${param.device}';
		var app_token = '${param.app_token}';
		var param = {
			t :new Date(),
			app_token:app_token
		};
		$.post("celebrate_depository_login_status.htm", param, function(data) {
			if(data.loginStatus == 1) {
				if(device) {
					window.location.href="/h5/ext/activity/invest_bill.htm?device=app&app_token="+app_token;
				} else {
					window.location.href="/h5/ext/activity/invest_bill.htm";
				}
			} else {
				if(device) {
// 					window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
					window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
				} else {
					window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
				}
			}
		}, "json");
	});
	
	$("#convertBill").click(function() {
		var device = '${param.device}';
		var app_token = '${param.app_token}';
		var param = {
			t :new Date(),
			app_token:app_token
		};
		$.post("celebrate_depository_login_status.htm", param, function(data) {
			if(data.loginStatus == 1) {
				if(device) {
					window.location.href="/h5/ext/activity/convert_bill.htm?device=app&app_token="+app_token;
				} else {
					window.location.href="/h5/ext/activity/convert_bill.htm";
				}
			} else {
				if(device) {
// 					window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
					window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
				} else {
					window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
				}
			}
		}, "json");
	});
	
	$("#shakeBill").click(function() {
		var device = '${param.device}';
		var app_token = '${param.app_token}';
		var param = {
			t :new Date(),
			app_token:app_token
		};
		$.post("celebrate_depository_login_status.htm", param, function(data) {
			if(data.loginStatus == 1) {
				if(device) {
					window.location.href="/h5/ext/activity/shake_bill.htm?device=app&app_token="+app_token;
				} else {
					window.location.href="/h5/ext/activity/shake_bill.htm";
				}
			} else {
				if(device) {
// 					window.location.href="/h5/ext/activity/celebrate_online.htm?device=app&app_view=login";
					window.location.href="/h5/ext/activity/celebrate_online.htm?app_view=acc";
				} else {
					window.location.href="/h5/login.htm?tab=account&returnUrl=/h5/ext/activity/celebrate_online.htm";
				}
			}
		}, "json");
	});
})

function getShareInfo(){
	var title = "要理财,来存吧!";
	var summary = "来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!";
	var url = "http://8.laicunba.com/h5/regist_new.jsp?invite_code=${inviteCode}&t="+new Date();
	window.share.onSumResult(summary,title,url);
	return{
		title:title,
		summary:summary,
		url:url
	}	
}

function getShareInfoIOS(){
	var title = "要理财,来存吧!";
	var summary = "来存吧票据理财,注册即送18888元理财金,新手宝7天年化收益率达20%!100万小伙伴的选择,让你的每笔财富增值!";
	var url = "http://8.laicunba.com/h5/regist_new.jsp?invite_code=${inviteCode}";
	return{
		title:title,
		summary:summary,
		url:url
	}	
}

//安卓右侧按钮
var android_right_btn=function(){
	window.button.onSumResults(
 	"https://cdn.laicunba.com/lcb/app-share-btn.png",
	'invite_info.htm?app_view=share'
	);
};
//IOS右侧按钮
var ios_right_btn=function(){
	return {
		"icon":"https://cdn.laicunba.com/lcb/app-share-btn.png",
		"href":'invite_info.htm?app_view=share'
	};
};
</script>
</body>
</html>